<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/21
 * Time: 9:47
 *首页产品图相关大图，小图，颜色编辑上传
 */

require('../include/init.inc.php');
$method = $id = $action = $status = '';
extract($_REQUEST, EXTR_IF_EXISTS);


//上下架
if ($action == 'modyindex') {
    $product = AdminProducts::getProductById($id);

    if (!$product) {
        Common::exitWithError(ErrorMessage::PRODUCT_NOT_EXIST, "one_page_shop/home_product.php");
    }


    if ($status == 'up') {
        //判断已有上架类型  如果不一样 打回
        $data = array('products_index' => '1');
    } else {
        $data = array('products_index' => '0');
    }
    $where = array('products_id' => $id);
    $ret = AdminProducts::update($where, $data);
    if ($ret) {
        SysLog::addLog(UserSession::getUserName(), 'Update', 'ProductsUpdate', $id, json_encode($data));
        Common::exitWithSuccess('更新完成', 'one_page_shop/home_product.php');
    } else {
        OSAdmin::alert("error");
    }
} else {
    //预览
    $product = AdminProducts::getProductById($id);
    Common::jumpUrl(SHOP_URL . 'index.php', true);
}



